package com.answer.controller;


import com.answer.model.dto.ScoringResultDto.ScoringResultAddDTO;
import com.answer.model.dto.ScoringResultDto.ScoringResultEditDTO;
import com.answer.model.dto.ScoringResultDto.ScoringResultQueryDTO;
import com.answer.model.dto.ScoringResultDto.ScoringResultUpdateDTO;
import com.answer.model.dto.app.AppAddDTO;
import com.answer.model.dto.app.AppQueryDTO;
import com.answer.model.dto.app.AppUpdateDTO;
import com.answer.model.reslut.Result;
import com.answer.model.reslut.ResultPage;
import com.answer.model.vo.AppVo;
import com.answer.model.vo.ScoringResultVo;
import com.answer.service.AppService;
import com.answer.service.ScoringResultService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/scoring/result")
public class ScoringResultController {

    @Resource
    private ScoringResultService scoringResultService;



    //查询列表
    @PostMapping("/query/all")
    public Result<ResultPage<ScoringResultVo>> queryAll(@RequestBody ScoringResultQueryDTO scoringResultQueryDTO){
        ResultPage<ScoringResultVo> scoringResultVoResultPage = scoringResultService.queryAll(scoringResultQueryDTO);
        return Result.success(scoringResultVoResultPage);
    }


    //根据id查询
    @GetMapping("/query/one/{id}")
    public Result<ScoringResultVo> queryOneById(@PathVariable Long id){
        ScoringResultVo scoringResultVo = scoringResultService.queryOneById(id);
        return Result.success(scoringResultVo);
    }


    //新增
    @PostMapping("/add")
    public Result addSortingResult(@RequestBody ScoringResultAddDTO scoringResultAddDTO){
        Boolean res = scoringResultService.addScoringResult(scoringResultAddDTO);
        return res? Result.success("添加成功"):Result.faile("添加失败");
    }

    //修改
    @PostMapping("/update")
    public Result update(@RequestBody ScoringResultUpdateDTO scoringResultUpdateDTO){
        Boolean res = scoringResultService.updateScoringResult(scoringResultUpdateDTO);
        return res? Result.success("修改成功"):Result.faile("修改失败");
    }

    //删除
    @PostMapping("/delete")
    public Result delete(Long id){
        Boolean res = scoringResultService.removeById(id);
        return res? Result.success("删除成功"):Result.faile("删除失败");
    }
}
